<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>忘记密码</title>
	<link rel="stylesheet" href="css/style.css">
	<script src="js/jquery.min.js"></script>
	<script src="js/requestUrl.js"></script>
	<style>
		.tab_content .input dl {
			margin-top: 5%;
		}

		.tab_content .input .login_btn {
			margin: 8% 0;
		}
	</style>
</head>

<body style="padding-bottom: 0 !important;">
	<div class="login">
		<div class="login_box">
			<div class="logo">
				<img src="img/u257.png" alt="">
			</div>
			<div class="con">
				<div class="tab_content">
					<ul>
						<li class="tabs" style="display: block;">
							<div class="input">
								<dl>
									<input type="text" class="phone" value="" placeholder="请输入手机号码">
								</dl>
								<dl>
									<input type="text" class="duanxin" value="" placeholder="请输入短信验证码">
									<span class="get_code">发送验证码</span>
								</dl>
								<dl>
									<input type="password" class="new_password" value="" placeholder="新密码"
										style="padding-left: 55px;">
								</dl>
								<dl>
									<input type="password" class="confirm_password" value="" placeholder="确认密码"
										style="padding-left: 55px;">
								</dl>
								<div class="login_btn">确定</div>
							</div>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<script src="js/layer/layer.js"></script>
	<script>
		var html = $('html').css("height")
		$('body').css("height", html)
		//点击获取验证码 + 短信倒计时
		function countDown() {
			let text = 60;
			$('.get_code').html(text);
			let timer = setInterval(function () {
				if (text == 1) {
					clearInterval(timer);
					flag = true;
					$('.get_code').html('发送验证码');
				} else {
					text -= 1;
					flag = false;
					$('.get_code').html(text);
				}
			}, 1000)
		}
		var flag = true;
		$('.get_code').click(function () {
			if (!flag) return false;
			var phone = $(".phone").val();
			if ($(".phone").val().length < 11) {
				layer.alert('请输入手机号码', {
					title: '提示'
				})
				return false;
			}
			// countDown();
			myAjax('/user/forgetSendSms', {
					phone: phone
				},
				function (data) {
					if (data.msg == "0") {
						layer.alert('发送成功', {
							title: '提示'
						})
						countDown();
					}
				},
				function (err) {
					console.log(err)
				})
		});
		$('.login_btn').click(function () {
			var phone = $(".phone").val();
			var duanxin = $(".duanxin").val();
			var new_password = $(".new_password").val();
			var confirm_password = $(".confirm_password").val();
			if (phone == '') {
				layer.alert('请输入手机号码', {
					title: '提示'
				})
				return
			}
			if (duanxin == '') {
				layer.alert('请输入短信验证码', {
					title: '提示'
				})
				return
			}
			if (new_password == '') {
				layer.alert('请输入新密码', {
					title: '提示'
				})
				return
			}
			if (confirm_password == '') {
				layer.alert('请再次输入密码', {
					title: '提示'
				})
				return
			}
			myAjax('/user/forgetPassword', {
					tel: phone,
					smsCode: duanxin,
					newPassword: new_password,
					confirmPassword: confirm_password,
				},
				function (data) {
					console.log(data)
					if (data.msg == "您当前暂未登录，请登录后在操作") {
						layer.alert(data.msg, {
							title: "提示",
							cancel: function () {
								window.location.href =
									"http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
							}
						}, function () {
							window.location.href =
								"http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
						});
						return false
					}
					if (data.msg == 0) {
						layer.alert('操作成功', {
							title: '提示'
						})
						window.location.href = "login.html";
					} else {
						layer.alert(data.msg, {
							title: '提示'
						})
					}
				},
				function (err) {
					console.log(err)
				})
		});
	</script>
</body>

</html>